home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / Scrollable.java < prev    next >
Text File  |  1998-06-30  |  5KB  |  122 lines

  1. /*
  2.  * @(#)Scrollable.java    1.2 98/01/30
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing;
  22.  
  23. import java.awt.Dimension;
  24. import java.awt.Rectangle;
  25.  
  26.  
  27. /** 
  28.  * An interface that provides information to a scrolling container
  29.  * like JScrollPane.  A complex component that's likely to be used 
  30.  * as a viewin a JScrollPane viewport (or other scrolling container) 
  31.  * should implement this interface.
  32.  * 
  33.  * @see JViewport
  34.  * @see JScrollPane
  35.  * @see JScrollBar
  36.  * @version 1.2 01/30/98
  37.  * @author Hans Muller
  38.  */
  39. public interface Scrollable  
  40. {
  41.     /**
  42.      * Returns the preferred size of the viewport for a view component.
  43.      * For example the preferredSize of a JList component is the size
  44.      * required to acommodate all of the cells in its list however the
  45.      * value of preferredScrollableViewportSize is the size required for
  46.      * JList.getVisibleRowCount() rows.   A component without any properties
  47.      * that would effect the viewport size should just return 
  48.      * getPreferredSize() here.
  49.      * 
  50.      * @return The preferredSize of a JViewport whose view is this Scrollable.
  51.      * @see JViewport#getPreferredSize
  52.      */
  53.     Dimension getPreferredScrollableViewportSize();
  54.  
  55.  
  56.     /**
  57.      * Components that display logical rows or columns should compute
  58.      * the scroll increment that will completely expose one new row
  59.      * or column, depending on the value of orientation.  Ideally, 
  60.      * components should handle a partially exposed row or column by 
  61.      * returning the distance required to completely expose the item.
  62.      * <p>
  63.      * Scrolling containers, like JScrollPane, will use this method
  64.      * each time the user requests a unit scroll.
  65.      * 
  66.      * @param visibleRect The view area visible within the viewport
  67.      * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
  68.      * @param direction Less than zero to scroll up/left, greater than zero for down/right.
  69.      * @return The "unit" increment for scrolling in the specified direction
  70.      * @see JScrollBar#setUnitIncrement
  71.      */
  72.     int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction);
  73.  
  74.  
  75.     /**
  76.      * Components that display logical rows or columns should compute
  77.      * the scroll increment that will completely expose one block
  78.      * of rows or columns, depending on the value of orientation. 
  79.      * <p>
  80.      * Scrolling containers, like JScrollPane, will use this method
  81.      * each time the user requests a block scroll.
  82.      * 
  83.      * @param visibleRect The view area visible within the viewport
  84.      * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
  85.      * @param direction Less than zero to scroll up/left, greater than zero for down/right.
  86.      * @return The "block" increment for scrolling in the specified direction.
  87.      * @see JScrollBar#setBlockIncrement
  88.      */
  89.     int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction);  
  90.     
  91.  
  92.     /**
  93.      * Return true if a viewport should always force the width of this 
  94.      * Scrollable to match the width of the viewport.  For example a noraml 
  95.      * text view that supported line wrapping would return true here, since it
  96.      * would be undesirable for wrapped lines to disappear beyond the right
  97.      * edge of the viewport.  Note that returning true for a Scrollable
  98.      * whose ancestor is a JScrollPane effectively disables horizontal
  99.      * scrolling.
  100.      * <p>
  101.      * Scrolling containers, like JViewport, will use this method each 
  102.      * time they are validated.  
  103.      * 
  104.      * @return True if a viewport should force the Scrollables width to match its own.
  105.      */
  106.     boolean getScrollableTracksViewportWidth();
  107.  
  108.     /**
  109.      * Return true if a viewport should always force the height of this 
  110.      * Scrollable to match the height of the viewport.  For example a 
  111.      * columnar text view that flowed text in left to right columns 
  112.      * could effectively disable vertical scrolling by returning
  113.      * true here.
  114.      * <p>
  115.      * Scrolling containers, like JViewport, will use this method each 
  116.      * time they are validated.  
  117.      * 
  118.      * @return True if a viewport should force the Scrollables height to match its own.
  119.      */
  120.     boolean getScrollableTracksViewportHeight();
  121. }
  122.